package cn.edu.jxust.core.infrastructure.mapper;

import cn.edu.jxust.common.domain.entity.AirType;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author QiuKangming
 * @since 2020-06-29
 */

public interface AirtypeMapper extends BaseMapper<AirType> {

    /**
     * 根据 id 获取气体名称
     * @param id 气体id号
     * @return String
     */
    @Select("SELECT air_name FROM t_airtype WHERE id = #{id} AND status = 1")
    String getAirNameById(Integer id);

    /**
     * 根据气体名称获得气体id号
     * @param airName 气体名称
     * @return Integer
     */
    @Select("SELECT id FROM t_airtype WHERE air_name = #{airName} AND status = 1")
    Integer getIdByAirName(String airName);

    /**
     * 根据监测气体名称查看是否存在该检测气体
     * @param airName 气体名称
     * @return int
     */
    @Select("SELECT COUNT(1) FROM t_airtype WHERE air_name = #{airName} AND status = 1")
    int isExistAirType(String airName);

}
